﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class InterFace : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        BankCard card1 = new BankCard();
        CreditCard card2 = new CreditCard();
        IPay[] pays = { card1, card2 };
        foreach(IPay pay in pays)
        {
            Response.Write(pay.GetName() + pay.Pay(0) + "<br>");
        }
    }
}
/// <summary>
/// I***表示接口
/// 支付接口
/// </summary>
interface IPay
{
    bool Pay(decimal price);
    string GetName();
}

/// <summary>
/// 储蓄卡
/// </summary>
class BankCard : IPay
{
    public string GetName()
    {
        return "储蓄卡";
    }

    public bool Pay(decimal price)
    {
        return true;
    }
}

/// <summary>
/// 信用卡
/// </summary>
class CreditCard : IPay
{
    public string GetName()
    {
        return "信用卡";
    }

    public bool Pay(decimal price)
    {
        return true;
    }
}